<?php

class wap_controller extends base_controller{

    var $defaultwg;
    function __construct($app){
        header("Cache-Control:no-store, no-cache, must-revalidate"); // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// 强制查询etag
        header('Progma: no-cache');
        $this->defaultwg = $this->defaultWorkground;
        parent::__construct($app);
        kernel::single('base_session')->start();

        $_GOTO = app::get('wap')->router()->gen_url(array('ctl'=>'passport','act'=>'index'), true);

        $auth = pam_auth::instance(pam_account::get_account_type('desktop'));
        $account = $auth->account();
        if(get_class($this)!='wap_ctl_passport' && !$account->is_valid()){
            echo "<script>location ='$_GOTO'</script>";
            exit;
        }

        $this->user = kernel::single('desktop_user');
        if(get_class($this)!='wap_ctl_passport'){
            $this->status = $this->user->get_status();
            if(!$this->status&&$this->status==0){
                $this->pagedata['link_url'] = $_GOTO;
                $this->pagedata['error_msg'] = '管理员未启用！';
                echo $this->fetch('auth_error.html');
                exit;
            }

            ###如果不是超级管理员就查询操作权限
            if(!$this->user->is_super()){
                if(!$this->user->has_permission('o2o_store_self')){
                    $this->pagedata['link_url'] = $_GOTO;
                    $this->pagedata['error_msg'] = '管理员没有门店权限！';
                    echo $this->fetch('auth_error.html');
                    exit;
                }
            }else{
                $this->pagedata['link_url'] = $_GOTO;
                $this->pagedata['error_msg'] = '超管不能登录门店系统！';
                echo $this->fetch('auth_error.html');
                exit;
            }
        }
    }

}